<?php

namespace ManiaLivePlugins\MLEPP\Karma\Gui\Windows;

use ManiaLive\PluginHandler\PluginHandler;
use ManiaLib\Gui\Elements\BgsPlayerCard;
use ManiaLive\Gui\Windowing\Controls\Pager;
use ManiaLib\Gui\Layouts\Flow;
use ManiaLib\Gui\Elements\Quad;
use ManiaLive\Gui\Windowing\Controls\Frame;
use ManiaLivePlugins\MLEPP\Core\Core;

class KarmaWindow extends \ManiaLive\Gui\Windowing\Window {
	protected $frame;
	protected $line;
	private $background;
	private $label;

	function initializeComponents() {

		$mlepp = \ManiaLivePlugins\MLEPP\Core\Mlepp::getInstance();

    	if(empty(Core::$widget_background)) {

			switch ($mlepp->gameVersion->name) {
				case "ManiaPlanet":
					$this->background = new \ManiaLib\Gui\Elements\BgsPlayerCard();
					$this->background->setSubStyle("BgPlayerCardBig");
					break;
				case "TmForever":
					$this->background = new \ManiaLib\Gui\Elements\Bgs1();
					$this->background->setSubStyle("BgList");
					break;
			}
        } else {
            $this->background = new Quad();
    		$this->background->setImage(Core::$widget_background, true);
        }

        $this->background->setSize(16,3.5);

        $this->frame = new Frame();
        $this->frame->applyLayout(new Flow());
        $this->frame->setSize(16,3);
        $this->frame->setPosition(11,1.5);
        $this->frame->setHalign("center");

        $this->label = new \ManiaLib\Gui\Elements\Label(12, 2);
        $this->label->setText('$s$eeeTrack Popularity');
        $this->label->setPosition(8,-2);
        $this->label->setTextSize(1.5);
        $this->label->setHalign("center");
	}

	function onLoad() {}

	function onDraw() {
        $this->clearComponents();
        $this->addComponent($this->background);
        $this->addComponent($this->label);
        $this->addComponent($this->frame);
	}

	function onResize() {
		//$this->frame->setSize($this->sizeX, $this->sizeY);
		//$this->background->setSize($this->sizeX, $this->sizeY);
	}

	function addItem($item) {
		$this->frame->addComponent($item);
	}

    function clearItems() {
		$this->frame->clearComponents();
	}

	function destroy() {
		parent::destroy();
	}
}
?>